/**
 * 
 */
package com.lanswon.qzsmk.service.cardManageService.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.UnavailableSecurityManagerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import com.lanswon.qzsmk.base.AccountContants;
import com.lanswon.qzsmk.base.AppContants;
import com.lanswon.qzsmk.base.BlackListContants;
import com.lanswon.qzsmk.base.CardContants;
import com.lanswon.qzsmk.base.DwzPage;
import com.lanswon.qzsmk.base.HttpContants;
import com.lanswon.qzsmk.dao.AppKindMapper;
import com.lanswon.qzsmk.dao.AppOpenRegMapper;
import com.lanswon.qzsmk.dao.BlackListGenMapper;
import com.lanswon.qzsmk.dao.BlackListRcMapper;
import com.lanswon.qzsmk.dao.BusiParamMapper;
import com.lanswon.qzsmk.dao.BusinessMapper;
import com.lanswon.qzsmk.dao.CardControlMapper;
import com.lanswon.qzsmk.dao.CardDataMapper;
import com.lanswon.qzsmk.dao.CardManageMapper;
import com.lanswon.qzsmk.dao.CardProdunctDefinitionMapper;
import com.lanswon.qzsmk.dao.CardTypeMapper;
import com.lanswon.qzsmk.dao.CertMapper;
import com.lanswon.qzsmk.dao.CertificateMapper;
import com.lanswon.qzsmk.dao.FeeRulesMapper;
import com.lanswon.qzsmk.dao.NationMapper;
import com.lanswon.qzsmk.dao.PersonalMapper;
import com.lanswon.qzsmk.dao.SubaccountPersonalMapper;
import com.lanswon.qzsmk.dao.SupplementCardMapper;
import com.lanswon.qzsmk.dao.TransGlideMapper;
import com.lanswon.qzsmk.dao.TxnDtlMapper;
import com.lanswon.qzsmk.exception.ApplicationException;
import com.lanswon.qzsmk.exception.ErrorCode;
import com.lanswon.qzsmk.model.ActiveUser;
import com.lanswon.qzsmk.model.AppKind;
import com.lanswon.qzsmk.model.AppOpenReg;
import com.lanswon.qzsmk.model.BlackListGen;
import com.lanswon.qzsmk.model.BlackListRc;
import com.lanswon.qzsmk.model.Business;
import com.lanswon.qzsmk.model.CardControl;
import com.lanswon.qzsmk.model.CardData;
import com.lanswon.qzsmk.model.CardManage;
import com.lanswon.qzsmk.model.Cert;
import com.lanswon.qzsmk.model.Personal;
import com.lanswon.qzsmk.model.SubaccountPersonal;
import com.lanswon.qzsmk.model.SupplementCardView;
import com.lanswon.qzsmk.service.cardManageService.SupplementCardService;
import com.lanswon.qzsmk.util.SequenceNumberUtil;
import com.lanswon.qzsmk.vo.ResultStatus;
import com.lanswon.qzsmk.vo.ResultVo;
import com.lanswon.qzsmk.vo.SupplementCardInfo;
import com.lanswon.qzsmk.vo.VoucherVo;

/**
 * @author sun
 *
 */
@Service
@Transactional
public class SupplementCardServiceImpl implements SupplementCardService {

	@Autowired
	SupplementCardMapper scm;

	@Autowired
	CertificateMapper cm;

	@Autowired
	CardProdunctDefinitionMapper cpdm;

	@Autowired
	PersonalMapper pm;

	@Autowired
	CardControlMapper ccm;

	@Autowired
	CardManageMapper cmm;

	@Autowired
	CardDataMapper cdm;

	@Autowired
	BusinessMapper bm;

	@Autowired
	CertMapper cem;

	@Autowired
	BusiParamMapper bpm;

	@Autowired
	BlackListGenMapper blgm;

	@Autowired
	BlackListRcMapper blrm;

	@Autowired
	CardTypeMapper ctm;

	@Autowired
	AppOpenRegMapper aorm;

	@Autowired
	SubaccountPersonalMapper spm;

	@Autowired
	AppKindMapper akm;
	
	@Autowired
	TransGlideMapper tgm;
	
	@Autowired
	FeeRulesMapper frsm;
	
	@Autowired
	TxnDtlMapper tdm;
	
	@Autowired
	NationMapper nationMapper;
	
	@Override
	public ResultVo querySupplementCard(SupplementCardInfo sci) {
		// String lossCertNo,
		// String paperType, String paperNo, int cp, int ps

		ResultVo rv = new ResultVo();
		ResultStatus rs = new ResultStatus();

		sci.setCardTypeCode(CardContants.CARD_TYPE_ANONYMOUS);
		sci.setCertType(CardContants.OFFICIAL_LOSS);
		sci.setCertStatus(CardContants.CERT_STATUS_VALID);
		sci.setCardStatus(CardContants.CARD_STATE_OFFICIAL_LOSS);
		List<SupplementCardView> list = scm.querySupplementCardByCondition(sci);
		List<SupplementCardInfo> l = new ArrayList<>();
		if (list.size() > 0) {
			for (SupplementCardView scv : list) {
				SupplementCardInfo s = new SupplementCardInfo();
				s.setPaperTypeName(cm.queryCertificateByCode(scv.getPaperType()).getCertificatesName());
				s.setPaperNo(scv.getPaperNo());
				s.setCardPName(cpdm.queryCardPCode(scv.getCardpCode()).getCardpName());
				s.setCardStatusName(CardContants.getCardStatusNameByCode(scv.getCardStatus()));
				s.setOldCitizenCardNo(scv.getCitizenCardNo());
				s.setLossCertNo(scv.getCertNo());
				s.setCardTypeName(ctm.queryCardTypeByCode(scv.getCardTypeCode()).getCardTypeName());
				s.setCustomerName(scv.getCustomerName());
				l.add(s);
			}
		}

		int totalCount = scm.querySupplementCardCountByCondition(sci);
		DwzPage<SupplementCardInfo> dp = new DwzPage<SupplementCardInfo>(sci.getCurrentPage(), sci.getNumPerPage(),
				totalCount);
		dp.setList(l);

		rs.setCode(HttpContants.RETURN_SUCCESS);
		rs.setMessage("返回成功");

		rv.setResultStatus(rs);
		rv.setServiceObject(dp);
		return rv;
	}

	@Override
	public Personal queryPersonalByPaperNo(String paperTypeName, String paperNo, String cardPName) throws Exception {
		if (StringUtils.isEmpty(paperTypeName) || StringUtils.isEmpty(paperNo)) {
			throw new ApplicationException(ErrorCode.OBJECT_IS_NULL, "paperType or paperNo is null !!!");
		}
		Personal p = pm.queryPersonalByPaperNo(cm.queryCertificateByName(paperTypeName).getCertificateType(), paperNo);
		p.setNationality(nationMapper.queryNationByCode(p.getNationality()).getNationname());
		Date now = new Date();
		p.setSupplementDate(now);
		String cardPCode = cpdm.queryCardPCodeByCardProductName(cardPName).getCardpCode();
		int supplementCardDays = bpm.queryBusiParamByCardPCode(cardPCode).getCocReleaseDays();
		Calendar c = Calendar.getInstance();
		c.setTime(now);
		c.add(Calendar.DAY_OF_MONTH, supplementCardDays);// 今天+n天
		p.setGetCardDate(c.getTime());

		return p;
	}

	@Override
	@Transactional(rollbackFor=Exception.class)
	public ResultVo commitSupplementCardInfo(SupplementCardInfo sci){

		ResultVo rv = new ResultVo();
		ResultStatus rs = new ResultStatus();

		ActiveUser activeUser = null;
		try {
			activeUser = (ActiveUser) SecurityUtils.getSubject().getSession().getAttribute("activeUser");

		} catch (UnavailableSecurityManagerException e) {
			e.printStackTrace();
			activeUser = new ActiveUser();
			activeUser.setUserName("用户");
			activeUser.setLoginName("用户");
			activeUser.setBranchName("互联网端");
			activeUser.setBranchNo("99999999");
			activeUser.setUserNo(99999999);
			activeUser.setUserId(99999999);
		}

		if (activeUser == null) {
			activeUser = new ActiveUser();
			activeUser.setUserName("用户");
			activeUser.setLoginName("用户");
			activeUser.setBranchName("互联网端");
			activeUser.setBranchNo("99999999");
			activeUser.setUserNo(99999999);
			activeUser.setUserId(99999999);
		}
		Date now = new Date();
		
		// 查询老卡
		CardData cardData = cdm.queryCardDataByCitizenCardNo(sci.getOldCitizenCardNo());
//		String cardTypeCode = ctm.queryCardTypeByCardTypeName(
//				sci.getCardTypeName()).getCardTypeCode();// 卡类型代码
		String cardTypeCode=cardData.getCardTypecode();
		CardManage c = new CardManage();
		c.setProcessId(UUID.randomUUID().toString().replace("-", ""));
		c.setApplyBranch(activeUser.getBranchName());
		c.setApplyBranchNo(activeUser.getBranchNo());
		c.setApplyDate(now);
		c.setApplyTellerNo(activeUser.getUserNo().toString());
		c.setApplyWay(CardContants.CLAIM_METHOD_SPORADIC);
		c.setCitizenCardNo(sci.getOldCitizenCardNo());
		// c.setProcessCode(CardContants.CARD_PROC_SUPPLEMENTARY_CARD_APPLICATION);
		// c.setProcessName(CardContants
		// .getCardProcNameByCode(CardContants.CARD_PROC_SUPPLEMENTARY_CARD_APPLICATION));
		
		
		// 更新原卡信息
		CardControl cc = ccm.queryCardControlByCitizenCardNo(sci.getOldCitizenCardNo());
		if (cc == null) {
			rs.setCode(ErrorCode.OBJECT_IS_NULL);
			rs.setMessage("查询无此市民卡信息");
			rv.setResultStatus(rs);
			return rv;
		}
		if (CardContants.CARD_STATE_CANCELLATION_NO_CARD.equals(cc.getCardStatus())) {
			rs.setCode(ErrorCode.OBJECT_IS_NULL);
			rs.setMessage("补卡信息提交成功，请勿重复提交");
			rv.setResultStatus(rs);
			return rv;
		}
		
		Cert cert = new Cert();
		cert.setCertNo(SequenceNumberUtil.generatorCertNo());
		cert.setCertType(CardContants.BACK_CARD_REGISTRATION);
		cert.setCardpCode(cardData.getCardpCode());
		cert.setCardTypecode(cardData.getCardTypecode());

		if (CardContants.CARD_TYPE_REGISTERED.equals(cardTypeCode)
				|| CardContants.CARD_TYPE_STANDARD.equals(cardTypeCode)) {
			cert.setName(sci.getCustomerName());
			cert.setPaperNo(sci.getPaperNo());
			cert.setPaperType(sci.getPaperType());
		}
		cert.setBranch(activeUser.getBranchName());
		cert.setBranchNo(activeUser.getBranchNo());
		if(!StringUtils.isEmpty(sci.getAgentName()))
		cert.setAgentName(sci.getAgentName());
		if(!StringUtils.isEmpty(sci.getAgentPaperNo()))
		cert.setAgentPaperNo(sci.getAgentPaperNo());
		if(!StringUtils.isEmpty(sci.getAgentPapertype()))
		cert.setAgentPapertype(sci.getAgentPapertype());
		cert.setCardControlId(cc.getCardControlId());
		cert.setCrtDate(now);
		cert.setCrtOperator(activeUser.getUserNo().toString());
		cert.setLastOperator(activeUser.getUserNo().toString());
		cert.setLastDate(now);
		cert.setTransCode("补卡注销");
		
		cem.insert(cert);

		Business bu = new Business();
		if (CardContants.CARD_TYPE_REGISTERED.equals(cardTypeCode)) {
			bu.setCustomerNo(cardData.getCustomerNo());
		}
		bu.setBusinessNo(SequenceNumberUtil.generatorBusinessNo());
		bu.setCardControlId(cc.getCardControlId());
		bu.setTransCode("交易代码");
		if(!StringUtils.isEmpty(sci.getAgentName()))
		bu.setAgentName(sci.getAgentName());
		if(!StringUtils.isEmpty(sci.getAgentPaperNo()))
		bu.setAgentPaperNo(sci.getAgentPaperNo());
		if(!StringUtils.isEmpty(sci.getAgentPapertype()))
		bu.setAgentPapertype(sci.getAgentPapertype());
		if(!StringUtils.isEmpty(sci.getAgentPhone()))
		bu.setAgentPhone(sci.getAgentPhone());
		bu.setBusiNum(1);
		bu.setTellerNo(activeUser.getUserNo().toString());
		bu.setTransDate(now);// 交易日期
		bu.setSeqStatus(CardContants.LSZT_NORMAL);
		if(!StringUtils.isEmpty(sci.getDesc()))
		bu.setRemark(sci.getDesc());
		bu.setCertNo(cert.getCertNo());
		bm.insert(bu);
		
		c.setCertNo(cert.getCertNo());
		c.setBusinessNo(bu.getBusinessNo());
		cmm.insert(c);

		cc.setCardPosition(CardContants.CARD_POSITION_OTHER);// 卡位置--其他
		cc.setCardStatus(CardContants.CARD_STATE_CANCELLATION_NO_CARD);// 卡状态--补卡注销
		cc.setLogoutDate(now);// 注销日期
		cc.setLastDate(now);// 最后修改时间
		cc.setLastOperator(activeUser.getUserNo().toString());// 最后一次操作员
		cc.setBlacklistFlag(CardContants.BLACKLIST_FLAG_INNER);// 黑名单标识-正常
		cc.setCurrProcId(c.getProcessId());
		cc.setClaimStatus(CardContants.CLAIM_STATUS_CANCEL);// 原卡注销
		ccm.updateCardControl(cc);

		// 创建新卡
		CardData ca = cdm.queryCardDataByCitizenCardNo(sci.getOldCitizenCardNo());

		ca.setCardDataId(null);
		ca.setCitizenCardNo(null);
		ca.setChcOriCitizenNo(sci.getOldCitizenCardNo());
		cdm.insert(ca);

		
		Calendar ccc = Calendar.getInstance();
		ccc.setTime(now);
		ccc.add(Calendar.DAY_OF_MONTH, bpm.queryBusiParamByCardPCode(ca.getCardpCode()).getReleaseDays());// 今天+n天===预计领卡日期
		

		CardControl cc1 = new CardControl();
		cc1.setCardPosition(CardContants.CARD_POSITION_COUNTER_EMPLOYEE);
		// cc.setClaimStatus(CardContants.CLAIM_STATUS_SUPPLEMENTARY_CARD_APPLICATION);//补卡已申请

		cc1.setCardStatus(CardContants.CARD_STATE_DISABLED);
		// cc1.setApplyBatchNo(applyBatchNo);
		cc1.setApplyDate(ccc.getTime());// 预计申领日期
		cc1.setReleaseDate(sci.getGetCardDate());
		cc1.setBlacklistFlag(CardContants.BLACKLIST_FLAG_NORMAL);
		cc1.setCardDataId(ca.getCardDataId());
		// cc1.setCardDate(cardDate);//制卡日期
		cc1.setCrtDate(now);
		cc1.setCrtOperator(activeUser.getUserNo().toString());
		
		// cc1.setDmgFlag(dmgFlag); // 损坏情况
		// cc1.setReleaseDate(sci.getGetCardDate());// 发卡日期
		cc1.setLastDate(now);
		cc1.setLastOperator(activeUser.getUserNo().toString());
		cc1.setRemark("补卡新卡的备注");
		cc1.setBlacklistFlag(CardContants.BLACKLIST_FLAG_NORMAL);
		cc1.setApplyType(CardContants.APPLY_TYPE_SUPPLEMENT);
		cc1.setClaimStatus(CardContants.CLAIM_STATUS_SUPPLEMENTARY_CARD_APPLICATION);
		cc1.setSupplementCardDate(sci.getSupplementCardDate());// 补卡日期

		ccm.insert(cc1);

		Cert ce = new Cert();
		ce.setCertNo(SequenceNumberUtil.generatorCertNo());
		ce.setCertType(CardContants.CARD_ISSUING_APPLY);
		ce.setCardpCode(ca.getCardpCode());
		ce.setCardTypecode(ca.getCardTypecode());
		ce.setName(sci.getCustomerName());
		ce.setPaperNo(sci.getPaperNo());
		ce.setPaperType(sci.getPaperType());
		ce.setBranch(activeUser.getBranchName());
		ce.setBranchNo(activeUser.getBranchNo());
		ce.setAgentName(sci.getAgentName() == null ? "" : sci.getAgentName());
		ce.setAgentPaperNo(sci.getAgentPaperNo() == null ? "" : sci.getAgentPaperNo());
		ce.setAgentPapertype(sci.getAgentPapertype() == null ? "" : sci.getAgentPapertype());
		ce.setCardControlId(cc1.getCardControlId());
		ce.setCrtDate(now);
		ce.setCrtOperator(activeUser.getUserNo().toString());
		ce.setLastOperator(activeUser.getUserNo().toString());
		ce.setLastDate(now);
		ce.setCardControlId(cc1.getCardControlId());

		Business b = new Business();
		b.setBusinessNo(SequenceNumberUtil.generatorBusinessNo());
		b.setCardpCode(ca.getCardpCode());
		b.setCustomerNo(ca.getCustomerNo());
		b.setCardControlId(cc1.getCardControlId());
		b.setTransCode("交易代码");
		b.setAgentName(sci.getAgentName() == null ? "" : sci.getAgentName());
		b.setAgentPaperNo(sci.getAgentPaperNo() == null ? "" : sci.getAgentPaperNo());
		b.setAgentPapertype(sci.getAgentPapertype() == null ? "" : sci.getAgentPapertype());
		b.setAgentPhone(sci.getAgentPhone() == null ? "" : sci.getAgentPhone());
		b.setBusiNum(1);
		b.setTellerNo(activeUser.getUserNo().toString());
		b.setTransDate(now);// 交易日期
		b.setSeqStatus(CardContants.LSZT_NORMAL);
		b.setRemark("补卡业务");
		b.setCertNo(ce.getCertNo());
		b.setCardControlId(cc1.getCardControlId());
		bm.insert(b);

		

		CardManage cm = new CardManage();
		cm.setProcessId(UUID.randomUUID().toString().replace("-", ""));
		cm.setApplyBranch(activeUser.getBranchName());
		cm.setApplyBranchNo(activeUser.getBranchNo());
		cm.setApplyDate(now);
		cm.setApplyTellerNo(activeUser.getUserNo().toString());
		// cm.setBatchNo();
		cm.setApplyWay(CardContants.CLAIM_METHOD_SPORADIC);
		// cm.setBusinessNo(b.getBusinessNo());
		// cm.setCardpCode(cardpCode);
		// cm.setCardSeqNo(cardSeqNo);
		// cm.setCitizenCardNo(citizenCardNo);
		// c.setProcessCode(CardContants.CARD_PROC_SUPPLEMENTARY_CARD_APPLICATION);
		 c.setProcessName("补卡申请");
		
		cm.setCertNo(ce.getCertNo());
		cm.setBusinessNo(b.getBusinessNo());
		cmm.insert(cm);
		cc1.setCurrProcId(cm.getProcessId());
		
		ccm.updateCardControl(cc1);

		ce.setBusinessNo(b.getBusinessNo());
		
		cem.insert(ce);
		List<AppOpenReg> aors = aorm.queryAppOpenRegByCitizenCardNo(sci.getOldCitizenCardNo(),
				AppContants.APP_STATUS_OPEN);
		for (AppOpenReg aor : aors) {
			aor.setStopDate(now);// 停用日期
			aor.setLastDate(now);
			aor.setAppStatus(AppContants.APP_STATUS_CLOSE);// 关闭应用
			aor.setIsValid(AccountContants.IS_DEPOSIT_YES);
			aor.setLastOperator(activeUser.getUserNo().toString());
			aor.setRemark(AppContants.APP_STATUS_CLOSE_SUPPLEMENTCARD);
			aorm.update(aor);
			AppKind ak = akm.queryAppKindByTypeCode(Integer.valueOf(aor.getAppType()));
			List<SubaccountPersonal> sps = spm.querySubaccountPersonalByAppFlag(ak.getAppFlag(),
					sci.getOldCitizenCardNo());

			for (SubaccountPersonal sp : sps) {
				sp.setFreezeStatus(AccountContants.FREEZE_STATUS_WHOLE);
				sp.setFreezeDate(now);
				sp.setFreezeAmount(sp.getTotalBalance());
				sp.setAccountStatus(AccountContants.ACCOUNT_STATUS_FROZEN);
				spm.update(sp);
			}
		}

		 // 黑名单
		BlackListGen bb = blgm.queryBlackListGenBycitizenCardNo(sci.getOldCitizenCardNo());
		if (bb == null) {
			bb.setCitizenCardNo(sci.getOldCitizenCardNo());
			bb.setCityCode(CardContants.CITY_CODE);
			// bb.setAppType(appType);//置黑应用类型
			// bb.setChipsInno(chipsInno);//接触卡内号
			// bb.setChipsLessInno(chipsLessInno);//非接卡内号
			// bb.setChipsLessNo(chipsLessNo);//非接芯片号
			// bb.setChipsNo(chipsNo);//接触芯片号
			bb.setBlCount(1);// 进黑名单次数
			bb.setBlReCount(0);// 解除黑名单次数
			bb.setBlReason(BlackListContants.BL_REASON_SUPPLEMENT_CARD_CANCELLATION);
			// bb.setBlReReason(blReReason);//解除黑名单原因
			bb.setLastBlRcDate(new Date());// 最后更新日期
			// bb.setCriticalLevel(criticalLevel);//严重级别 0-9, 严重级别由低至高.
			bb.setCurStatus(BlackListContants.BL_CUR_STATUS_TAKE_EFFECT);// 当前状态
			bb.setAvailDate(new Date());// 生效日期
			// bb.setRelieveDate(relieveDate);//解除日期
			bb.setBlackMode(BlackListContants.BL_BLACK_MODE_SYSTEM);// 置黑方式
			bb.setReleaseSys(BlackListContants.BL_PUBLISHING_SYSTEM_LIST_ALl);//
			// 发布系统列表
			blgm.insert(bb);

		} else {
			bb.setBlCount(bb.getBlCount() + 1);
			bb.setBlReason(BlackListContants.BL_REASON_SUPPLEMENT_CARD_CANCELLATION);
			bb.setLastBlRcDate(new Date());// 最后更新日期
			bb.setAvailDate(new Date());// 生效日期
			bb.setCurStatus(BlackListContants.BL_CUR_STATUS_TAKE_EFFECT);// 当前状态
			bb.setBlackMode(BlackListContants.BL_BLACK_MODE_SYSTEM);// 置黑方式
			bb.setReleaseSys(BlackListContants.BL_PUBLISHING_SYSTEM_LIST_ALl);// 发布系统列表

			blgm.update(bb);
		}

		// 黑名单记录表
		BlackListRc blr = new BlackListRc();
		// blr.setAppType(appType);//置黑应用类型
		blr.setCitizenCardNo(sci.getOldCitizenCardNo());// 市民卡号
		blr.setRegisterType(BlackListContants.BL_CUR_STATUS_TAKE_EFFECT);// 登记类型
		// 1.生效
		// 2.解除
		blr.setAvailDate(new Date());// 生效日期
		// blr.setRelieveDate(relieveDate);//解除日期
		blr.setBlackMode(BlackListContants.BL_BLACK_MODE_SYSTEM);// 置黑方式
		// 0-系统;
		// 1-手工
		blr.setBlReason(BlackListContants.BL_REASON_SUPPLEMENT_CARD_CANCELLATION);// 进黑名单原因
		// blr.setBlReReason(blReReason);//解除黑名单原因
		// blr.setCriticalLevel(criticalLevel);//严重级别 0-9, 严重级别由低至高.
		blr.setBlSource(BlackListContants.BL_SOURCE_ALL);// 黑名单来源
		// blr.setReleaseSys(releaseSys);//下发系统
		// blr.setTransCode(transCode);//交易代码
		// blr.setBusinessNo(businessNo);//综合业务流水号
		// blr.setDoubtTrNo(doubtTrNo);/可疑交易流水号
		// blr.setssLockTrNo(lockTrNo);//锁卡交易流水号

		blrm.insert(blr);
		
		String str = "{\"title\":\""+"补卡登记凭证"+"\",\"type\":\""+"supplierCardRegister"+"\",\"certNo\":\""+ce.getCertNo()
		+"\",\"busType\":\""+CardContants.getCertTypeNameByCode(ce.getCertType())+"\",\"cardType\":\""+ce.getCardTypecode()
		+"\",\"citizenCardNo\":\""+sci.getOldCitizenCardNo()+"\",\"net\":\""+activeUser.getBranchName()+"\",\"operator\":\""
		+activeUser.getUserNo().toString()+"\",\"date\":\""+DateFormatUtils.format(new Date(), "yyyy-MM-dd")+"\"}";
		ce.setData(str);
		ce.setTransCode("补卡登记");
		cem.update(ce);
		VoucherVo vv = new VoucherVo();
		vv.setCertNo(ce.getCertNo());
		vv.setOldCitizenCardNo(sci.getOldCitizenCardNo());
		vv.setBusinessTypeName(CardContants.getCertTypeNameByCode(ce.getCertType()));
		vv.setExpectCardDate(sci.getGetCardDate());
		vv.setDate(DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
		vv.setOperator(activeUser.getUserNo().toString());
		vv.setNet(activeUser.getBranchName());
		vv.setCardType(ca.getCardTypecode());

		rs.setCode(HttpContants.RETURN_SUCCESS);
		rs.setMessage("返回成功");

		rv.setResultStatus(rs);
		rv.setServiceObject(vv);

		return rv;
	}

}
